﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMove : MonoBehaviour {
	public GameObject bulletPre;
	public Transform firePos1;
	public Transform firePos2;
	public Transform firePos3;
	public int Planyblood = 20;
	// Use this for initialization
	void Start () {

	}

	// Update is called once per frame
	void Update ()
	{
		if (Input.GetKey (KeyCode.W)) {
			transform.Translate (Vector3.up * Time.deltaTime * 3);
		}
		if (Input.GetKey (KeyCode.S)) {
			transform.Translate (Vector3.down * Time.deltaTime * 3);
		}
		if (Input.GetKey (KeyCode.A)) {
			if (transform.position.x <= 2.3f) {
				transform.Translate (Vector3.right * Time.deltaTime * 3);
			}
		}
		if (Input.GetKey (KeyCode.D)) {
			if (transform.position.x >= -2.3f) {

				transform.Translate (Vector3.left * Time.deltaTime * 3);
			}
		}
		if (Input.GetKeyDown (KeyCode.Space)) {
			Instantiate (bulletPre, firePos1.position, Quaternion.identity);
			Instantiate (bulletPre, firePos2.position, Quaternion.identity);
			Instantiate (bulletPre, firePos3.position, Quaternion.identity);
		}
		if (Planyblood <= 0) {
			Destroy (gameObject);
		}
	}
}

